﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ScratchNet.runtime.IOControl
{
    /// <summary>
    /// 数字输入
    /// </summary>
    public class WaitInputBaseExpression : Expression
    {
        public override string ReturnType => "any";
        public InPutValues InPutValues { get; set; }
        public BoolOperator BoolOperator { get; set; }
        public TimeoutOperator  TimeoutOperator { get; set; }

        public WaitInputBaseExpression()
        {
            InPutValues = InPutValues.input1;
            BoolOperator = BoolOperator.TRUE;
            TimeoutOperator = TimeoutOperator.Continue;
        }
        protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            Completion completion = new Completion();
            completion.ExecStatementStr = GetConvertStr();
            return completion;
        }
        public override Descriptor Descriptor
        {
            get
            {
                Descriptor desc = new Descriptor();
                desc.Add(new TextItemDescriptor(this, "等待 ", true));
                desc.Add(new SelectionItemDescriptor(this, "InPutValues", new object[] { "input1", "input2", },
                    new object[] { InPutValues.input1, InPutValues.input2 }));
                desc.Add(new TextItemDescriptor(this, "  等于  ", true));

                desc.Add(new SelectionItemDescriptor(this, "BoolOperator", new object[] { "TRUE", "FALSE", },
                    new object[] { BoolOperator.TRUE, BoolOperator.FALSE }));
                desc.Add(new TextItemDescriptor(this, ", 超时 ", true));
                desc.Add(new SelectionItemDescriptor(this, "TimeoutOperator", new object[] { "继续", "报警", },
                    new object[] { TimeoutOperator.Continue, TimeoutOperator.Warning }));
                return desc;
            }
        }

        public override string Type
        {
            get { return "WaitInputBaseExpression"; }
        }

        private string GetConvertStr()
        {
            return ($"WaitInputBaseExpression.GetConvertStr()");
        }
    }
    public enum InPutValues
    {
        input1 = 1,
        input2
    }
    public enum BoolOperator
    {
        TRUE,
        FALSE
    }

    public enum TimeoutOperator
    {
        Continue,
        Warning,
    }

}
